import http from '@/plugins/axios'

// 列表
export function getEmployeeManagement(data) {
  return http({
    method: 'POST',
    url: '/sys/user/list',
    data: data
  })
}

// 新增
export function addEmployeeManagement(data) {
  console.log(data)
  return http({
    method: 'POST',
    url: '/sys/user/save',
    data: data
  })
}

// 获取详情
export function getEmployeeManagementDetail(id, row) {
  return http({
    method: 'POST',
    url: '/sys/user/info',
    data: { userId: row.userId }
  })
}

// 修改
export function updateEmployeeManagement(data) {
  return http({
    method: 'POST',
    url: '/sys/user/update',
    data: data
  })
}

// 删除
export function removeEmployeeManagement(ids) {
  return http({
    method: 'POST',
    url: '/sys/user/delete',
    data: ids
  })
}

// 设置密码
export function setPassword(data) {
  return http({
    method: "POST",
    url: '/sys/user/setPassword',
    data
  })
}

export function validFlowerName(data) {
  return http({
    silence: true,
    method: "POST",
    url: '/sys/user/validFlowerName',
    data
  })
}

export function validNo(data) {
  return http({
    silence: true,
    method: "POST",
    url: '/sys/user/validNo',
    data
  })
}

export function getRoleList() {
  return http({
    method: 'POST',
    url: '/sys/role/list',
    data: {
      condition: {},
      page: {
        index: 1,
        size: 999999999999
      },
      sort: { order: '', sidx: '' }
    }
  }).then(res => {
    return res.list || []
  })
}

export function searchDispatchRole(data) {
  return http({
    method: "POST",
    url: '/sys/role/searchDispatchRole',
    data
  }).then(res => {
    return { userId: data.userId, roleIdList: res || [] }
  })
}

export function dispatchRole(data) {
  return http({
    method: "POST",
    url: '/sys/role/dispatchRole',
    data
  })
}

// 发送离职短信
export function sendResignationSms(data) {
  return http({
    method: "POST",
    url: '/sys/user/sendResignationSms',
    data
  })
}

export function getDeptNoItems(companyNo) {
  return http({
    method: 'POST',
    url: '/ykf/companyDept/page',
    data: {
      condition: { companyNo },
      page: { index: 1, size: 99999999999999 }
    }
  }).then(res => {
    return (res.list || []).map(item => ({ value: item.deptId, label: item.deptName }))
  })
}
